keep-nip46: fail closed instead of panicking on unrouted encryption method#827
Conversation
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Hardening found by an audit of panic sites on untrusted-input decode paths.
The encryption dispatch in the NIP-46 server re-matches the client-supplied method string inside the arm that the outer dispatch routes
nip44_encrypt/nip44_decrypt/nip04_encrypt/nip04_decryptinto, with_ => unreachable!(). The invariant holds today, but it couples two match arms in different places on an attacker-controlled string: if the outer list ever gains a method the inner match does not handle, an unsupported method string panics the signer process (denial of service) instead of returning an error.Changes
unreachable!()arm with a logged, fail-closedUnsupported methoderror response.Audit context
A sweep of
unwrap()/expect()/panic!/unreachable!in non-test code across the wire and IPC decode surfaces (keep-frost-net protocol/event/node, keep-nip46 request handling, keep-mobile FFI) found no attacker-reachable panic besides this fragile spot. The remaining sites are locally-verified invariants (expect("just inserted")immediately after a map insert), startup-time initialization, or environmental conditions, none reachable from untrusted input.Verification
cargo test -p keep-nip46: 189 passed.cargo clippy -p keep-nip46 --all-targets: clean.